from typing import List


class Solution:
    def badSensor(self, sensor1: List[int], sensor2: List[int]) -> int:
        size = len(sensor1)
        for i in range(size):
            if sensor1[i] != sensor2[i]:
                if i == size - 1:
                    return -1
                if sensor1[i] == sensor2[i + 1] and sensor2[i] == sensor1[i + 1]:
                    if i == size - 2:
                        return -1
                    if sensor1[-2] == sensor2[-1]:
                        return 1
                    if sensor2[-2] == sensor1[-1]:
                        return 2
                elif sensor1[i] == sensor2[i + 1]:
                    return 1
                elif sensor2[i] == sensor1[i + 1]:
                    return 2
        return -1


if __name__ == "__main__":
    print(Solution().badSensor(sensor1=[2, 3, 4, 5], sensor2=[2, 1, 3, 4]))  # 1
    print(Solution().badSensor(sensor1=[2, 2, 2, 2, 2], sensor2=[2, 2, 2, 2, 5]))  # -1
    print(Solution().badSensor(sensor1=[2, 3, 2, 2, 3, 2], sensor2=[2, 3, 2, 3, 2, 7]))  # 2
